package com.mdinic.blogovi.front.page.blogpost;

import java.util.List;

import org.apache.wicket.markup.html.panel.Panel;

import com.mdinic.blogovi.front.common.AbstractMorePage;
import com.mdinic.blogovi.front.page.BSession;
import com.mdinic.blogovi.front.page.blogpost.BlogPostPanel.BlogPostPanelType;
import com.mdinic.blogovi.model.BlogPost;

public class NewLinksPage extends AbstractMorePage<BlogPost> {

    private static final long serialVersionUID = 1L;

    public NewLinksPage() {
        super(5, false);
    }

    @Override
    protected List<BlogPost> getList(int firstResult, int maxResults) {
        if (BSession.get().getFavouriteBlogType() == null) {
            return BlogPost.findNotPromotedApprovedBlogPostEntries(firstResult, maxResults);
        } else {
            return BlogPost.findNotPromotedApprovedBlogPostEntries(firstResult, maxResults, BSession.get()
                    .getFavouriteBlogType());
        }
    }

    @Override
    protected Panel createPanel(List<BlogPost> list) {
        return new BlogPostPanel(list, BlogPostPanelType.LIST);
    }
}
